﻿<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script> 
    <link href="../../Styles/jquery.validate.css" rel="stylesheet" type="text/css" /> 
    <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script> 
     <script src="../../Scripts/jquery.validator.messages.js" type="text/javascript"></script>     
    <script type="text/javascript" src="../../Scripts/jquery.query.js"></script>
    <script src="../js/blockUI.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server"   method="post" action="../AjaxHandler/UserMessageEditHandler.ashx?action=Edit">
    <div>
        <table>
           
            <tr>
                <td>
                    姓名
                </td>
                <td>
                    <input type="text" id="name" name="name"  readonly="readonly"/>
                </td>
            </tr>
            <tr>
                <td>
                    邮箱
                </td>
                <td>
                    <input type="text" id="email" name="email" readonly="readonly" />
                </td>
            </tr>
            <tr>
                <td>
                    留言
                </td>
                <td>
                    <textarea id="message" rows="5" cols="20" name="message" readonly="readonly" ></textarea>
                </td>
            </tr>
            <tr>
                <td>
                    留言时间
                </td>
                <td>
                    <input type="text" id="createtime" name="createtime" readonly="readonly" />
                </td>
            </tr>
            <tr>
                <td>
                    答复
                </td>
                <td>
                    <textarea id="remark" rows="5" cols="20" name="remark" ></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="button" id="btn_Save" value="答复" /><input type="button" id="btn_Refuse" value="拒绝" /><input type="button" id="btn_Delete" value="删除" /><input type="button" id="btn_Back" value="返 回"  onclick="javascript:history.back();" />
                </td>
            </tr>
        </table>
    </div>
    <input id="hidCode" name="hidCode" type="hidden" value="-1" />  
    </form>    
     <script type="text/javascript">
         $(document).ready(function () {
             var code = $.query.get("code");
             $("#hidCode").val(code);

             var BindData = function () {              
                 if (code != "-1") {   $.blockUI({ message: "<h2>数据加载中.......</h2>", css: { width: "300px", height: "50px"} });
                     $.post("../AjaxHandler/UserMessageEditHandler.ashx", { action: "Get", hidCode: code }, function (data) {
                         $("#name").val(data.Name);
                         $("#email").val(data.Email);
                         $("#message").val(data.Message);
                         $("#remark").val(data.Remark);
                         $("#createtime").val(new Date(parseInt(data.CreateTime.substr(6))).toLocaleString());
                           $.unblockUI();
                     });
                 } else {

                     $("input").removeAttr("readonly");
                     $("#createtime").val(new Date().toLocaleDateString());
                     $("textarea").removeAttr("readonly");
                     $("#btn_Delete").hide();
                     $("#btn_Refuse").hide();

                 }
               
             }
             BindData();

             $("#btn_Save").click(function () {
                 $("#form1").attr("action", "../AjaxHandler/UserMessageEditHandler.ashx?action=Answner");
                 $("#form1").submit();

             });
             $("#btn_Refuse").click(function () {
                 $("#form1").attr("action", "../AjaxHandler/UserMessageEditHandler.ashx?action=Refuse");
                 $("#form1").submit();

             });
             $("#btn_Delete").click(function () {
                 $.post("../AjaxHandler/UserMessageEditHandler.ashx?t=" + new Date(), { action: "Delete", code: $("#hidCode").val() }, function (d) {
                     if (d == "0") {
                         alert("删除失败！");
                     } else {
                         location.href = d;
                     }
                 })
             });
         });

    </script>
</body>
</html>
